package com.esri.core.tasks.query;

import com.esri.core.internal.tasks.ags.c.d;
import com.esri.core.internal.tasks.ags.c.g;
import com.esri.core.internal.tasks.e;
import com.esri.core.io.EsriSecurityException;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.CallbackListener;
import com.esri.core.map.FeatureResult;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;

/* loaded from: classes.dex */
public class QueryTask {
    UserCredentials _credentials;
    String _url;

    public QueryTask(String str) {
        this._url = str;
    }

    public QueryTask(String str, UserCredentials userCredentials) throws EsriSecurityException {
        this._url = str;
        this._credentials = userCredentials == null ? null : userCredentials.getCopy();
    }

    public FeatureResult execute(QueryParameters queryParameters) throws Exception {
        return new g(queryParameters.getParams(), this._url, this._credentials).execute();
    }

    public Future<FeatureResult> execute(final QueryParameters queryParameters, final CallbackListener<FeatureResult> callbackListener) {
        return e.b.submit(new Callable<FeatureResult>() { // from class: com.esri.core.tasks.query.QueryTask.1
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            public FeatureResult call() throws Exception {
                FeatureResult featureResult = null;
                try {
                    featureResult = QueryTask.this.execute(queryParameters);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    } else {
                        throw e;
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return featureResult;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(featureResult);
                }
                return featureResult;
            }
        });
    }

    public Map<Long, FeatureResult> executeRelationshipQuery(RelatedQueryParameters relatedQueryParameters) throws Exception {
        return new d(relatedQueryParameters.getParams(), this._url, this._credentials).execute();
    }

    public Future<Map<Long, FeatureResult>> executeRelationshipQuery(final RelatedQueryParameters relatedQueryParameters, final CallbackListener<Map<Long, FeatureResult>> callbackListener) {
        return e.b.submit(new Callable<Map<Long, FeatureResult>>() { // from class: com.esri.core.tasks.query.QueryTask.2
            @Override // java.util.concurrent.Callable
            public Map<Long, FeatureResult> call() throws Exception {
                Map<Long, FeatureResult> map = null;
                try {
                    map = QueryTask.this.executeRelationshipQuery(relatedQueryParameters);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    } else {
                        throw e;
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return map;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(map);
                }
                return map;
            }
        });
    }
}
